"""
给出一个 32 位的有符号整数，你需要将这个整数中每位上的数字进行反转
"""


class Solution:
    def reverse(self, x: 'int') -> 'int':
        x = str(x)
        list_ = list(x)
        list_.reverse()
        if list_[-1] == "-":
            list_.remove('-')
            list_.insert(0, '-')
        if list_[0] == 0:
            list_.remove('0')
        x = ''.join(list_)
        x = int(str(x))
        if x < (-2**31) or x > (2**31-1):
            x = 0
        return x
